import {observable, action} from 'mobx';
import { WeaTools } from 'ecCom';
import {WeaTableNew} from 'comsMobx'
const {TableStore} = WeaTableNew
import * as mobx from 'mobx'
import { ListStoreCharts } from './listStoreCharts'
import * as API_LIST from '../../apis/chart/fnaCostDetailExpense'

/**
 * 费用明细自定义的Store
 */
export class FnaCostDetailExpenseStore extends ListStoreCharts{

	//高级搜索条件值
	@observable SearchParams = {

    };

    //显示
    charFlag = false;

    @observable dataKey = "";
    @observable tableStore = new TableStore();

	constructor(){
		super();
		this.title = "费用明细自定义";
        this.pageType = "FnaCostDetailExpense";
	}


    //初始化数据
	initDatas = () => {
		this.doSearch();//初始化数据
	}

	//初始化高级搜索
	initInfo = () => {
        API_LIST.fnaCostDetailExpenseInfo().then(data => {
        	const {conditions} = data;
        	this.condition = conditions;
        	this.form.initFormFields(conditions);
        	this.setShowSearchAd(true);
        });
    }

    //搜索
    doSearch = (params = {}) => {
        const searchParamsAd = this.form.getFormParams();
        const newParams = { ...this.SearchParams, ...searchParamsAd, ...params };    
        
        this.loading = true;
        API_LIST.costDetailExpenseChart(newParams).then(data =>{
            this.permisflag = data.flag;
            if(this.permisflag != "failed"){
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
                this.charFlag = true;
                this.havePermis = data.havePermis;
            }
            this.loading = false; 
        }); 
    }
}